;;Make a 16x16 lenslet array, that focusses with an f_number f_number
;;to give an image size where lambda/lenslet_pitch is im_size pixels.

function make_lenslet, psize,lenslet_pitch, m_pix, im_size, l_sense, f_number=f_number

f_number = 2*m_pix/l_sense
y0 = lenslet_pitch/4/f_number
lenslet = make_pupil(psize,lenslet_pitch/m_pix*2, focus=-4*!pi*y0/l_sense)
lenslet[0:psize/2-lenslet_pitch/m_pix/2,*]=0
lenslet[psize/2+lenslet_pitch/m_pix/2:*,*]=0
lenslet[*,0:psize/2-lenslet_pitch/m_pix/2]=0
lenslet[*,psize/2+lenslet_pitch/m_pix/2:*]=0
lenslet = lenslet + shift(lenslet,lenslet_pitch/m_pix,0) + $
 shift(lenslet,lenslet_pitch/m_pix,lenslet_pitch/m_pix)+ shift(lenslet,0,lenslet_pitch/m_pix)
lenslet = lenslet + shift(lenslet,2*lenslet_pitch/m_pix,0) + $
 shift(lenslet,2*lenslet_pitch/m_pix,2*lenslet_pitch/m_pix)+ shift(lenslet,0,2*lenslet_pitch/m_pix)
lenslet = lenslet + shift(lenslet,4*lenslet_pitch/m_pix,0) + $
 shift(lenslet,4*lenslet_pitch/m_pix,4*lenslet_pitch/m_pix)+ shift(lenslet,0,4*lenslet_pitch/m_pix)
lenslet = shift(lenslet,-3.5*lenslet_pitch/m_pix, -3.5*lenslet_pitch/m_pix)

return, lenslet

end
